package com.example.moonshine.baidumap.View.Activity;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.os.Bundle;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;

import com.example.moonshine.baidumap.Modle.MsgStaticdata;
import com.example.moonshine.baidumap.R;

@SuppressLint("Registered")
public class BaiduActivity extends Activity {

    double  latitudeend;
    double  longiduteend;
    @SuppressLint("SetJavaScriptEnabled")
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.map_activity);
        getGpsdata();
        final WebView webView = (WebView)findViewById(R.id.webView_map);
        webView.setWebViewClient(new WebViewClient(){
            @Override
            public boolean shouldOverrideUrlLoading(WebView view, String url) {
                return false;// 返回false
            }
        });

        webView.getSettings().setJavaScriptEnabled(true);
        webView.getSettings().setAppCacheEnabled(true);
        //设置 缓存模式
        webView.getSettings().setCacheMode(WebSettings.LOAD_DEFAULT);
        // 开启 DOM storage API 功能
        webView.getSettings().setDomStorageEnabled(true);

        webView.loadUrl("http://api.map.baidu.com/marker?location="+latitudeend+","+longiduteend+"&title=目的地&content="+MsgStaticdata.gpsPosition+"&output=html");
    }
    @SuppressLint("UseValueOf")
    public void getGpsdata(){
        String[] arr = MsgStaticdata.getGps().split(",");
        String latitude1 =  arr[1];
        String longitude1 =arr[0];
        latitudeend = new Double(latitude1);
        longiduteend = new Double(longitude1);
    }

}
